/********************************************
 * 功能说明: 
 * 模块名称: 
 * 系统名称: 
 * 软件版权: 
 * 系统版本: 1.0.0
 * 开发人员: Frank
 * 开发时间: 2019/8/31 19:14
 * 审核人员: 
 * 相关文档: 
 * 修改记录: 修改日期 修改人员 修改说明
 *********************************************/
package com.spring.arch.message.common.sender.sms.config;

import com.spring.arch.message.common.sender.sms.SmsSender;
import com.spring.arch.message.common.sender.sms.impl.AliSmsSender;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static com.spring.arch.message.common.sender.sms.config.SmsProperties.SMS_PREFIX;

/**
 * @author Frank
 * @version 1.0.0.1
 * @since 2019/8/31 19:14
 */
@Configuration
@EnableConfigurationProperties(SmsProperties.class)
public class SmsAutoConfiguration {

    /**
     * Sms sender sms sender.
     * @param smsProperties the sms properties
     * @return the sms sender
     */
    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnProperty(prefix = SmsProperties.SMS_PREFIX,name = "aliyun.sign-name")
    public SmsSender aliyunSmsSender(SmsProperties smsProperties) {
        SmsProperties.Aliyun aliyun = smsProperties.getAliyun();
        return new AliSmsSender(smsProperties.isEnabled(), aliyun.getSignName(), aliyun.getAccessKeyId(), aliyun.getAccessKeySecret());
    }

//    /**
//     * Sms sender sms sender.
//     * @param smsProperties the sms properties
//     * @return the sms sender
//     */
//    @Bean
//    @ConditionalOnMissingBean
//    @ConditionalOnProperty(prefix = SMS_PREFIX,name = "monyun.user-id")
//    public SmsSender monyunSmsSender(SmsProperties smsProperties) {
//        SmsProperties.Monyun monyun = smsProperties.getMonyun();
//        return new MonyunSmsSender(smsTemplateRepository, smsProperties.isEnabled(), monyun);
//    }

}
